<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui">

    <ui:composition template="/template.xhtml">
        <ui:define name="title">
            <h:outputText value="#{bundle.ViewOrderesTitle}"></h:outputText>
        </ui:define>
        <ui:define name="body">
            <h:panelGroup id="messagePanel" layout="block">
                <h:messages errorStyle="color: red" infoStyle="color: green" layout="table"/>
            </h:panelGroup>
            <h:form>
                <p:panelGrid columns="4"  style=" width: 1400px; tab-size: 12" id="view">

                    <f:facet name="header">
                        <h3>Pedido</h3>
                    </f:facet> 

                    <h:outputText value="#{bundle.ViewClientLabel_name}"  />
                    <h:outputText value="#{orderesController.selected.client.name}" title="#{bundle.ViewClientTitle_name}"/>
                    <h:outputText value="#{bundle.ViewAddressLabel_street}"/>
                    <h:outputText value="#{orderesController.selected.client.address.street}" title="#{bundle.ViewClientTitle_address}"/>
                    <h:outputText value="#{bundle.ViewAddressLabel_city}"/>
                    <h:outputText value="#{orderesController.selected.client.address.city}" title="#{bundle.ViewAddressTitle_city}"/>
                    <h:outputText value="#{bundle.ViewAddressLabel_stateORprovince}"/>
                    <h:outputText value="#{orderesController.selected.client.address.stateORprovince}" title="#{bundle.ViewAddressTitle_stateORprovince}"/>
                    <h:outputText value="#{bundle.ViewAddressLabel_postalCode}"/>
                    <h:outputText value="#{orderesController.selected.client.address.postalCode}" title="#{bundle.ViewAddressTitle_postalCode}"/>
                    <h:outputText value="#{bundle.ViewAddressLabel_contry}"/>
                    <h:outputText value="#{orderesController.selected.client.address.contry}" title="#{bundle.ViewAddressTitle_contry}"/>


                    <f:facet name="footer">
                        <h:panelGroup id="messagePanel" layout="block">
                            <h:messages errorStyle="color: red" infoStyle="color: green" layout="table"/>
                        </h:panelGroup>
                        <h:outputText escape="false" value="#{bundle.ListOrderesEmpty}" rendered="#{!orderesController.verificaLista()}"/>
                        <h:panelGroup rendered="#{orderesController.verificaLista()}"> 
                            <p:dataTable value="#{orderesController.itensLista}" var="item" style="border:solid 1px">

                                <f:facet name="footer">
                                    <h:outputText value="Via WebApplication" /> 
                                </f:facet>

                                <p:column>
                                    <f:facet name="header">
                                        <h:outputText value="Item"/>
                                    </f:facet>
                                    <h:outputText value="#{item.ID}"/>
                                </p:column>

                                <p:column>
                                    <f:facet name="header">
                                        <h:outputText value="Descricao"/>
                                    </f:facet>
                                    <h:outputText value="#{item.product.description}"/>    
                                </p:column>


                                <p:column>
                                    <f:facet name="header">
                                        <h:outputText value="Preço Unitario"/>
                                    </f:facet>
                                    <h:outputText value="$ #{item.product.price}0"/>
                                </p:column>
                                <p:column>
                                    <f:facet name="header">
                                        <h:outputText value="QTD"/>
                                    </f:facet>
                                    <h:outputText value="#{item.quanttity}"/>
                                </p:column>
                                <p:column width="400">
                                    <f:facet name="header">
                                        <h:outputText value="Valor"/>
                                    </f:facet>
                                    <h:outputText value=" $ #{item.product.price * item.quanttity}"/>
                                </p:column>
                                
                                <p:columnGroup type="footer">  
                                    <p:row>  
                                        <p:column colspan="4" footerText="Valor Total:"  
                                                  style="text-align:right"  />  
                                        <p:column footerText="$ #{orderesController.valorTotal()}" />  
                                    </p:row>  
                                </p:columnGroup>  


                            </p:dataTable>
                        </h:panelGroup>
                    </f:facet>

                </p:panelGrid>


                <br/>


                <br /><br/>

                <br />
                <p:commandButton action="#{orderesController.prepareList}" value="#{bundle.ViewOrderesShowAllLink}"/>
                <br />
                <br />
                <h:link outcome="/home" value="#{bundle.ViewOrderesIndexLink}"/>

            </h:form>
        </ui:define>
    </ui:composition>

</html>
